Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add memberClusters selection #87

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

MatousJobanek
Copy link
Contributor

so we can specify that particular users should be provisioned to a specific member cluster only (eg intel in DevSandbox)

Copy link
Contributor

@mfrancisc mfrancisc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 . Nice job!

I have only few minor comments for the tests, but they can be addressed later.

pkg/assets/kubesaw_admins_test.go Show resolved Hide resolved
// should be skipped if there is at least one selected member cluster
// and
// the name is either empty or is not specified in the selected member clusters
return len(s.MemberClusters) > 0 && (memberName == "" || !slices.Contains(s.MemberClusters, memberName))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that there can be no "apply this entity to any member cluster"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. It's already the default behavior for the cases when you don't specify any permissions in any member cluster.

@@ -47,7 +46,7 @@ func ensureUsers(ctx *clusterContext, objsCache objectsCache) error {
ctx.Printlnf("-> Ensuring Users and its RoleBindings...")

for _, user := range ctx.kubeSawAdmins.Users {
if ctx.specificKMemberName != "" && slices.Contains(user.Selector.SkipMembers, ctx.specificKMemberName) {
if user.Selector.ShouldBeSkippedForMember(ctx.specificKMemberName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we keep the empty name check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same, the check is part of the method

@@ -16,7 +15,7 @@ type clusterContext struct {
func ensureServiceAccounts(ctx *clusterContext, objsCache objectsCache) error {
ctx.Printlnf("-> Ensuring ServiceAccounts and its RoleBindings...")
for _, sa := range ctx.kubeSawAdmins.ServiceAccounts {
if ctx.specificKMemberName != "" && slices.Contains(sa.Selector.SkipMembers, ctx.specificKMemberName) {
if sa.Selector.ShouldBeSkippedForMember(ctx.specificKMemberName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we keep the empty name check ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's already part of ShouldBeSkippedForMember method logic

@MatousJobanek MatousJobanek merged commit 8d63298 into kubesaw:master Oct 18, 2024
5 of 7 checks passed
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.00%. Comparing base (9e9b2f4) to head (5a3540c).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #87      +/-   ##
==========================================
- Coverage   69.59%   68.00%   -1.60%     
==========================================
  Files          43       44       +1     
  Lines        2565     3175     +610     
==========================================
+ Hits         1785     2159     +374     
- Misses        589      825     +236     
  Partials      191      191              
Files with missing lines Coverage Δ
pkg/assets/kubesaw_admins.go 100.00% <100.00%> (ø)
pkg/cmd/generate/cli_configs.go 73.62% <100.00%> (-1.04%) ⬇️
pkg/cmd/generate/cluster.go 76.92% <100.00%> (-3.08%) ⬇️

... and 37 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants